package com.yzc.mihuyou;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yzc.mihuyou.entity.Topic;
import com.yzc.mihuyou.mapper.TopicMapper;
import com.yzc.mihuyou.mapper.UserimgMapper;
import com.yzc.mihuyou.util.CommentUtils;
import com.yzc.mihuyou.util.MailClient;
import com.yzc.mihuyou.vo.Person;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.thymeleaf.TemplateEngine;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

//import net.sf.json.JSONObject;
@SpringBootTest
public class text2 {
    @Test
    public void text() {

    }

    @Autowired
    private MailClient mailClient;

    @Autowired
    TopicMapper topicMapper;
    @Autowired
    UserimgMapper userimgMapper;

    @Test
    public void text2() {
        Topic topic = new Topic();
        topic.setTopicCome("测试");
        topicMapper.insert(topic);
    }

    @Test
    public void text3() {
        String a = "[{imga:['https://upload-bbs.mihoyo.com/upload/2019/01/18/b46e488a0a75f39484a32530cf6eef14.png?x-oss-process=image/resize,s_150/quality,q_80/auto-orient,0/interlace,1/format,jpg'],name:['吐了个槽']}]";
        JSONArray array=JSONArray.fromObject(a);
        for(int i = 0; i < array.size(); i++)

        {
            JSONObject jsonObject = array.getJSONObject(i);
            Person obj=((Person) JSONObject.toBean(jsonObject, Person.class)); //转成实体对象，此处的Object替换成你需要转换的类
            System.out.println(obj.imga[0]);
        }
    }
    @Test
    public  void  se(){
        Page page = new Page<>(1,10);
        userimgMapper.selectPage(page,null);
        for (Object record : page.getRecords()) {
            System.out.println(record);
        }
    }

    @Test
    public void text4(){
       List list=  CommentUtils.strUwe(",1,23,4,2");
       list.forEach(System.out::println);
    }

//    获取图片的路径


    //发送html页面
    @Test
    public void testHtmlMail() {
        mailClient.sendMail("3097089520@qq.com", "短信验证码");
    }
}
